﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Data;
using System.Web.Configuration;
using System.Security.Cryptography;
using System.Text;

namespace HospitalSystem.Admin
{
    public partial class UserProfiles : System.Web.UI.Page
    {
        DataTable dt = new DataTable();
        string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
                BindData();
        }
        private void MessageBox(string msg)
        {
            Label lbl = new Label();
            lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "')</script>";
            Page.Controls.Add(lbl);
        }
        protected void BindData()
        {
            SqlConnection scon = new SqlConnection(constr);
            dt.Columns.Add("Staff_id");
            dt.Columns.Add("Firstname");
            dt.Columns.Add("Lastname");
            dt.Columns.Add("PID");
            dt.Columns.Add("Email");
            dt.Columns.Add("Gender");
            dt.Columns.Add("DOB");
            
            Label ULB = (Label)Master.FindControl("UserLabel");
            SqlCommand cmd = new SqlCommand("SELECT Staff_id,Firstname,Lastname,PID,Email,Gender,DOB FROM Employee WHERE Username =@UID", scon);
            scon.Open();
            cmd.Parameters.AddWithValue("@UID", ULB.Text);
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                dt.Rows.Add(reader["Staff_id"].ToString(), reader["Firstname"].ToString(), reader["Lastname"].ToString(), reader["PID"].ToString(), reader["Email"].ToString(),reader["Gender"].ToString(), reader["DOB"].ToString());
            }
            else
            {
               // MessageBox("System Error!");
            }
            reader.Close(); 
            GridView1.DataSource = dt;
            GridView1.DataBind();
            scon.Close();
           
        }
    }
}